package com.edu.exam.entity.assessment.generation;

import com.edu.exam.enums.assessment.generation.AssessmentType;
import com.edu.exam.enums.assessment.generation.AssessmentMethod;
import com.edu.exam.enums.assessment.generation.GenerationMethod;
import com.edu.exam.enums.assessment.generation.ReviewStatus;
import com.edu.exam.enums.assessment.AssessmentTaskStatus;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 考核任务实体类
 * 所属模块：B-05 考核计划管理模块
 * 对应数据库表：assessment_generation_task
 *
 * <p>考核任务生成模块的核心实体，记录自动生成的考核任务信息。
 * 每个任务对应具体的教学班和考核安排，包含任务的基本信息、
 * 生成方式、关联数据等完整内容。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@Table(name = "assessment_task")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AssessmentGenerationTask {

    /**
     * 任务ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 任务编号
     */
    @Column(name = "task_code", unique = true, length = 50, nullable = false)
    private String taskCode;

    /**
     * 任务名称
     */
    @Column(name = "task_name", length = 200, nullable = false)
    private String taskName;

    /**
     * 任务描述
     */
    @Column(name = "task_description", length = 1000)
    private String taskDescription;

    /**
     * 教学班ID
     */
    @Column(name = "teaching_class_id", nullable = false)
    private Long teachingClassId;

    /**
     * 教学班名称
     */
    @Column(name = "teaching_class_name", length = 200)
    private String teachingClassName;

    /**
     * 课程ID
     */
    @Column(name = "course_id", nullable = false)
    private Long courseId;

    /**
     * 课程名称
     */
    @Column(name = "course_name", length = 200)
    private String courseName;

    /**
     * 考核方案ID
     */
    @Column(name = "assessment_scheme_id", nullable = false)
    private Long assessmentSchemeId;

    /**
     * 考核方案名称
     */
    @Column(name = "assessment_scheme_name", length = 200)
    private String assessmentSchemeName;

    /**
     * 考核类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "assessment_type", length = 50, nullable = false)
    private AssessmentType assessmentType;

    /**
     * 考核方式
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "assessment_method", length = 50, nullable = false)
    private AssessmentMethod assessmentMethod;

    /**
     * 计划考核日期
     */
    @Column(name = "scheduled_date")
    private LocalDateTime scheduledDate;

    /**
     * 计划考核时长（分钟）
     */
    @Column(name = "duration_minutes")
    private Integer durationMinutes;

    /**
     * 考核地点
     */
    @Column(name = "location", length = 200)
    private String location;

    /**
     * 应考人数
     */
    @Column(name = "expected_students")
    private Integer expectedStudents;

    /**
     * 实考人数
     */
    @Column(name = "actual_students")
    private Integer actualStudents;

    /**
     * 任务状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "task_status", length = 20, nullable = false)
    private AssessmentTaskStatus taskStatus;

    /**
     * 生成方式
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "generation_method", length = 20, nullable = false)
    private GenerationMethod generationMethod;

    /**
     * 生成批次ID
     */
    @Column(name = "batch_id")
    private Long batchId;

    /**
     * 优先级
     */
    @Column(name = "priority", nullable = false)
    private Integer priority;

    /**
     * 权重
     */
    @Column(name = "weight", precision = 5, scale = 2)
    private BigDecimal weight;

    /**
     * 满分
     */
    @Column(name = "full_score", precision = 5, scale = 2)
    private BigDecimal fullScore;

    /**
     * 及格分
     */
    @Column(name = "passing_score", precision = 5, scale = 2)
    private BigDecimal passingScore;

    /**
     * 任务配置（JSON格式）
     */
    @Column(name = "task_config", columnDefinition = "TEXT")
    private String taskConfig;

    /**
     * 附加信息（JSON格式）
     */
    @Column(name = "additional_info", columnDefinition = "TEXT")
    private String additionalInfo;

    /**
     * 是否启用
     */
    @Column(name = "is_enabled", nullable = false)
    private Boolean isEnabled;

    /**
     * 是否锁定
     */
    @Column(name = "is_locked", nullable = false)
    private Boolean isLocked;

    /**
     * 删除标记
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted;

    /**
     * 创建人ID
     */
    @Column(name = "created_by", nullable = false)
    private Long createdBy;

    /**
     * 创建人姓名
     */
    @Column(name = "created_by_name", length = 100)
    private String createdByName;

    /**
     * 更新人ID
     */
    @Column(name = "updated_by")
    private Long updatedBy;

    /**
     * 更新人姓名
     */
    @Column(name = "updated_by_name", length = 100)
    private String updatedByName;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @LastModifiedDate
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    /**
     * 审核人ID
     */
    @Column(name = "reviewed_by")
    private Long reviewedBy;

    /**
     * 审核人姓名
     */
    @Column(name = "reviewed_by_name", length = 100)
    private String reviewedByName;

    /**
     * 审核时间
     */
    @Column(name = "reviewed_time")
    private LocalDateTime reviewedTime;

    /**
     * 审核状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "review_status", length = 20)
    private ReviewStatus reviewStatus;

    /**
     * 审核意见
     */
    @Column(name = "review_comment", length = 1000)
    private String reviewComment;

    /**
     * 执行人ID
     */
    @Column(name = "executed_by")
    private Long executedBy;

    /**
     * 执行人姓名
     */
    @Column(name = "executed_by_name", length = 100)
    private String executedByName;

    /**
     * 执行时间
     */
    @Column(name = "executed_time")
    private LocalDateTime executedTime;

    /**
     * 完成时间
     */
    @Column(name = "completed_time")
    private LocalDateTime completedTime;

}